import ProTable from '@ant-design/pro-table';
import { FC } from 'react';
import { ProTableProps } from '@ant-design/pro-table/lib/typing';

const KTable: FC<ProTableProps<any, any>> = props => {
  let req;
  if (props.request) {
    // 将protable的接口格式转成自己的
    req = async (p: any, s: any, b: any) => {
      const res: any = await props.request?.(p, s, b);
      return {
        success: res.success,
        data: res.data.items,
        total: res.data.total,
      };
    };
  }
  return <ProTable {...props} request={req} />;
};

export default KTable;
